package com.common.handler;

import java.util.Map;

import com.common.utils.BeanUtils;

/**
 * PCL参数处理器-针对params中的某个key下的Object做处理
 * @author iuie
 * @param <T>
 */
public abstract class PCLAbstractObjectParamHandler<T> extends PCLAbstractParamHandler {
	
	protected T objParam;
	
	public PCLAbstractObjectParamHandler(String key) {
		super(key);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Map<String, Object> handle(Map<String, Object> params) {
		if (params == null || this.key ==null || params.get(this.key) == null) {
			return params;
		}
		this.objParam = (T) params.get(this.key);
		Map<String, Object> objMap = BeanUtils.beanToMap(this.objParam);
		Map<String, Object> newObjMap = handleObjectMap(objMap);
		params.put(this.key, newObjMap);
		return params;
	}

	/**
	 * 处理params&lt;key&gt;对象
	 * @param objMap
	 * @return
	 * @author iuie
	 * @date 2017年7月25日 下午2:20:44
	 */
	public abstract Map<String, Object> handleObjectMap(Map<String, Object> objMap);
	
}
